<template>
  <div style="margin-top: 9px">
    <el-select v-model="currentProject1" size="small" placeholder="请选择项目" @change="handlerChangeProject">
      <el-option
        v-for="item in projects"
        :key="item.projectId"
        :label="item.projectName"
        :value="item.projectId"
      />
    </el-select>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
  name: 'Index',
  data() {
    return {
      currentProject1: undefined
    }
  },
  computed: {
    ...mapGetters([
      'projects',
      'currentProject'
    ])
  },
  created(){
     this.currentProject1 = this.currentProject.projectId
  },
  methods: {
    handlerChangeProject(project) {
      let _project = this.projects.find((el) => {
        return el.projectId === project
      })
      this.$store.dispatch('user/setCurrentProject', _project)
    }
  }
  // },
  // mounted() {
  //   this.currentProject1 = this.projects[0];
  // },
}
</script>

<style scoped>

</style>
